              ; pink noise (1/f) generator
              ; (actually white noise into a one-pole low-pass filter)
              ; based on noise generator from Dr. Bubb but extended to 24 bits
              ; uses simple one-tap recursive filter
              ;
              ; written by: Quinn Jensen (jensenq@qcj.icon.com)
              ;
              
              include "tdsg.a56"
              ;***************************************************************
              ;
              ;       sample rate computations
              ;
              ;***************************************************************
              
P:0076        dot
X:0010                org     x:$10
              
X:0010 000001 NSTATE  dc      1               ;STATE OF NOISE GENERATOR (SHIFT REG)
              
              
Y:0000                org     y:$0
              
P:0076                org     p:dot           ;go back to P-space
              ;
              ; non-interrupt code
              ;
              
P:0076        hf_init
P:0076 44F400         MOVE    #$FEEDEE,X0         ;INITIAL STATE OF NOISE GENERATOR
P:0077 FEEDEE
P:0078 441000         MOVE    X0,X:<NSTATE
P:0079 00000C         rts
              
              ;
              ; fs = 32.552083 kHz
              ;
              
P:007A        hf_comp
P:007A 0D0066         jsr     <saveregs
P:007B 0BF080         jsr     NOISE
P:007C 00008D
P:007D 45F400         move            #.005,x1
P:007E 00A3D7
P:007F 47F400         move            #.990,y1
P:0080 7EB852
P:0081 21C400         move            a,x0
P:0082 4484A1         mpyr    x0,x1,a x:<out_l,x0
P:0083 2000C3         macr    x0,y1,a
P:0084 560400         move            a,x:<out_l
P:0085 0BF080         jsr     NOISE
P:0086 00008D
P:0087 21C400         move            a,x0
P:0088 4485A1         mpyr    x0,x1,a x:<out_r,x0
P:0089 2000C3         macr    x0,y1,a
P:008A 560500         move            a,x:<out_r
P:008B 0D006F         jsr     <restregs
P:008C 00000C         rts
              
              ;       NOISE GENERATION ROUTINE.  THIS ROUTINE USES A 15 BIT SHIFT
              ;       REGISTER LEFT JUSTIFIED IN THE VARIABLE "NSTATE".  AFTER THE STATE
              ;       IS LOADED, IT IS CHECKED TO SEE IF IT IS NORMALIZED.  IF IT IS
              ;       NORMALIZED (TOP TWO BITS ARE DIFFERENT), A 1 IS SET AS THE INPUT
              ;       TO THE SHIFT REGISTER AND THE REGISTER IS SHIFTED AND SAVED.
              ;
              ;         B23     B22                            B9      B8
              ;        ______________________________________________
              ;       | S14   | S13 |                        | S0   |
              ;       |       |     |      . . .             |      |<----------
              ;       |_______|_____|________________________|_______          |
              ;           |      |                                             |
              ;            \    /                                              |
              ;              XOR                                               |
              ;               \_________________________________________________
              ;
              ;
              ;       ASSUMES SCALING MODE IS OFF
              ;
P:008D        NOISE                                   ;DO NOISE GENERATION LOOP
P:008D 56901B         CLR     B       X:<NSTATE,A     ;GET A ZERO IN B
P:008E 44F403         TST     A   #>$000001,X0        ;CHECK A, GET A 1 IN LSB POSITION
P:008F 000001
P:0090 02C048         TNR     X0,B                    ;IF NORMALIZED, THEN XOR=1
P:0091 200010         ADD     B,A                     ;SET LSB
P:0092 200032         ASL     A                       ;SHIFT BITS
P:0093 541000         MOVE    A1,X:<NSTATE            ;SAVE STATE
P:0094 00000C         RTS                             ;RETURN WITH STATE
              
                      END

Summary of psect usage

                 section seg base last top      used       avail    total
-------------------------------------------------------------------------


Symbol Table
-------------------------------------
         ssi_int 000061
            ssix 000010
           NOISE 00008D
     init_stereo 000059
           start 000040
           in_rs 000003
           in_ls 000002
            in_r 000001
            in_l 000000
             dot 000076
        mainloop 000060
         hf_comp 00007A
         hf_init 000076
        saveregs 000066
           savey 00000B
           savex 00000A
          saveb2 000009
         saveb10 000008
          savea2 000007
         savea10 000006
        restregs 00006F
           out_r 000005
           out_l 000004
          NSTATE 000010
          m_scl1 00000F
          m_scl0 00000E
           m_scl 00C000
          m_ssl1 00000D
          m_ssl0 00000C
           m_ssl 003000
          m_hpl1 00000B
          m_hpl0 00000A
           m_hpl 000C00
          m_ibl2 000005
          m_ibl1 000004
          m_ibl0 000003
           m_ibl 000038
          m_ial2 000002
          m_ial1 000001
          m_ial0 000000
           m_ial 000007
           m_ipr 00FFFF
           m_rdf 000007
           m_tde 000006
           m_roe 000005
           m_tue 000004
           m_rfs 000003
           m_tfs 000002
           m_if1 000001
           m_if0 000000
            m_if 000002
          m_srie 00000F
          m_stie 00000E
           m_sre 00000D
           m_ste 00000C
           m_mod 00000B
           m_gck 00000A
           m_syn 000009
           m_fsl 000008
          m_sckd 000005
          m_scd2 000004
          m_scd1 000003
          m_scd0 000002
           m_scd 00001C
           m_of1 000001
           m_of0 000000
            m_of 000003
           m_psr 00000F
           m_wl1 00000E
           m_wl0 00000D
            m_wl 006000
            m_dc 001F00
            m_pm 0000FF
           m_tsr 00FFEE
            m_sr 00FFEE
           m_crb 00FFED
           m_cra 00FFEC
            m_tx 00FFEF
            m_rx 00FFEF
           m_tcm 00000F
           m_rcm 00000E
           m_scp 00000D
           m_cod 00000C
            m_cd 000FFF
            m_r8 000007
            m_fe 000006
            m_pe 000005
            m_or 000004
          m_idle 000003
          m_rdrf 000002
          m_tdre 000001
          m_trne 000000
          m_tmie 00000D
           m_tie 00000C
           m_rie 00000B
          m_ilie 00000A
            m_te 000009
            m_re 000008
          m_woms 000007
           m_rwi 000006
          m_wake 000005
           m_sbk 000004
          m_wds2 000002
          m_wds1 000001
          m_wds0 000000
           m_wds 000003
          m_sccr 00FFF2
           m_ssr 00FFF1
           m_scr 00FFF0
          m_stxa 00FFF3
          m_stxh 00FFF6
          m_stxm 00FFF5
          m_stxl 00FFF4
          m_srxh 00FFF6
          m_srxm 00FFF5
          m_srxl 00FFF4
           m_dma 000007
           m_hf1 000004
           m_hf0 000003
            m_hf 000018
           m_hcp 000002
          m_htde 000001
          m_hrdf 000000
           m_hf3 000004
           m_hf2 000003
          m_hcie 000002
          m_htie 000001
          m_hrie 000000
           m_htx 00FFEB
           m_hrx 00FFEB
           m_hsr 00FFE9
           m_hcr 00FFE8
           m_pcd 00FFE5
         m_pcddr 00FFE3
           m_pcc 00FFE1
           m_pbd 00FFE4
         m_pbddr 00FFE2
           m_pbc 00FFE0
           m_bcr 00FFFE
errors=0
